# eric7.Plugins.CheckerPlugins.CodeStyleChecker.pycodestyle

### Global Attributes

ARITHMETIC_OP
BENCHMARK_KEYS
BLANK_EXCEPT_REGEX
BLANK_LINES_CONFIG
COMPARE_NEGATIVE_REGEX
COMPARE_SINGLETON_REGEX
COMPARE_TYPE_REGEX
DEFAULT_EXCLUDE
DEFAULT_IGNORE
DOCSTRING_REGEX
DUNDER_REGEX
ERRORCODE_REGEX
EXTRANEOUS_WHITESPACE_REGEX
FSTRING_END
FSTRING_MIDDLE
FSTRING_START
HUNK_REGEX
INDENT_REGEX
INDENT_SIZE
KEYWORDS
KEYWORD_REGEX
LAMBDA_REGEX
MAX_DOC_LENGTH
MAX_LINE_LENGTH
NEWLINE
OPERATOR_REGEX
PROJECT_CONFIG
PyCF_ONLY_AST
REPORT_FORMAT
SINGLETONS
SKIP_COMMENTS
SKIP_TOKENS
STARTSWITH_DEF_REGEX
STARTSWITH_GENERIC_REGEX
STARTSWITH_INDENT_STATEMENT_REGEX
STARTSWITH_TOP_LEVEL_REGEX
TSTRING_END
TSTRING_MIDDLE
TSTRING_START
UNARY_OPERATORS
USER_CONFIG
WHITESPACE
WHITESPACE_AFTER_COMMA_REGEX
WHITESPACE_AFTER_DECORATOR_REGEX
WS_NEEDED_OPERATORS
WS_OPTIONAL_OPERATORS
_SYMBOLIC_OPS
__version__
_checks
noqa

### Classes

BaseReport | Collect the results of the checks.
Checker | Load a Python source file, tokenize it, check coding style.
DiffReport | Collect and print the results for the changed lines only.
FileReport | Collect the results of the checks and print the filenames.
StandardReport | Collect and print the results of the checks.
StyleGuide | Initialize a PEP-8 instance with few options.

### Functions

_add_check |
_break_around_binary_operators | Private function to reduce duplication.
_get_parameters |
_is_binary_operator |
_is_eol_token |
_is_one_liner |
_main | Parse options and run checks on Python source.
_parse_multi_options | Split and strip and discard empties.
ambiguous_identifier | Never use the characters 'l', 'O', or 'I' as variable names.
bare_except | When catching exceptions, mention specific exceptions when possible.
blank_lines | Separate top-level function and class definitions with two blank lines.
break_after_binary_operator | Avoid breaks after binary operators.
break_before_binary_operator | Avoid breaks before binary operators.
comparison_negative | Negative comparison should be done using "not in" and "is not".
comparison_to_singleton | Comparison to singletons should use "is" or "is not".
comparison_type | Object type comparisons should always use isinstance().
compound_statements | Compound statements (on the same line) are generally discouraged.
continued_indentation | Continuation lines indentation.
expand_indent | Return the amount of indentation.
explicit_line_join | Avoid explicit line join between brackets.
extraneous_whitespace | Avoid extraneous whitespace.
filename_match | Check if patterns contains a pattern that matches filename.
get_parser | Create the parser for the program.
imports_on_separate_lines | Place imports on separate lines.
indentation | Use indent_size (PEP8 says 4) spaces per indentation level.
is_string_literal |
maximum_doc_length | Limit all doc lines to a maximum of 72 characters.
maximum_line_length | Limit all lines to a maximum of 79 characters.
missing_whitespace | Surround operators with the correct amount of whitespace.
missing_whitespace_after_keyword | Keywords should be followed by whitespace.
module_imports_on_top_of_file | Place imports at the top of the file.
mute_string | Replace contents with 'xxx' to prevent syntax matching.
normalize_paths | Parse a comma-separated list of paths.
parse_udiff | Return a dictionary of matching lines.
process_options | Process options passed either via arglist or command line args.
python_3000_invalid_escape_sequence | Invalid escape sequences are deprecated in Python 3.6.
read_config | Read and parse configurations.
readlines | Read the source code.
register_check | Register a new check object.
stdin_get_value | Read the value from stdin.
tabs_obsolete | On new projects, spaces-only are strongly recommended over tabs.
tabs_or_spaces | Never mix tabs and spaces.
trailing_blank_lines | Trailing blank lines are superfluous.
trailing_whitespace | Trailing whitespace is superfluous.
update_counts | Adds one to the counts of each appearance of characters in s, for characters in counts
whitespace_around_comma | Avoid extraneous whitespace after a comma or a colon.
whitespace_around_keywords | Avoid extraneous whitespace around keywords.
whitespace_around_named_parameter_equals | Don't use spaces around the '=' sign in function arguments.
whitespace_around_operator | Avoid extraneous whitespace around an operator.
whitespace_before_comment | Separate inline comments by at least two spaces.
whitespace_before_parameters | Avoid extraneous whitespace.

## BaseReport

Collect the results of the checks.

### Derived from

None

### Class Attributes

print_filename

### Class Methods

None

### Methods

BaseReport |
error | Report an error, according to options.
error_args | Report an error, according to options.
get_count | Return the total count of errors and warnings.
get_file_results | Return the count of errors and warnings for this file.
get_statistics | Get statistics for message codes that start with the prefix.
increment_logical_line | Signal a new logical line.
init_file | Signal a new file.
print_benchmark | Print benchmark numbers.
print_statistics | Print overall statistics (number of errors and warnings).
start | Start the timer.
stop | Stop the timer.

### Static Methods

None

#### BaseReport (Constructor)

BaseReport(options)

#### BaseReport.error

error(line_number, offset, text, check)

Report an error, according to options.

#### BaseReport.error_args

error_args(line_number, offset, text, check, *args)

Report an error, according to options.

#### BaseReport.get_count

get_count(prefix='')

Return the total count of errors and warnings.

#### BaseReport.get_file_results

get_file_results()

Return the count of errors and warnings for this file.

#### BaseReport.get_statistics

get_statistics(prefix='')

Get statistics for message codes that start with the prefix.

prefix='' matches all errors and warnings prefix='E' matches all errors prefix='W' matches all warnings prefix='E4' matches all errors that have to do with imports

#### BaseReport.increment_logical_line

increment_logical_line()

Signal a new logical line.

#### BaseReport.init_file

init_file(filename, lines, expected, line_offset)

Signal a new file.

#### BaseReport.print_benchmark

print_benchmark()

Print benchmark numbers.

#### BaseReport.print_statistics

print_statistics(prefix='')

Print overall statistics (number of errors and warnings).

#### BaseReport.start

start()

Start the timer.

#### BaseReport.stop

stop()

Stop the timer.

Up

## Checker

Load a Python source file, tokenize it, check coding style.

### Derived from

None

### Class Attributes

None

### Class Methods

None

### Methods

Checker |
build_tokens_line | Build a logical line from tokens.
check_all | Run all checks on the input file.
check_ast | Build the file's AST and run all AST checks.
check_logical | Build a line from tokens and run all logical checks on it.
check_physical | Run all physical checks on a raw input line.
generate_tokens | Tokenize file, run physical line checks and yield tokens.
init_checker_state | Prepare custom state for the specific checker plugin.
maybe_check_physical | If appropriate for token, check current physical line(s).
readline | Get the next line from the input buffer.
report_invalid_syntax | Check if the syntax is valid.
run_check | Run a check plugin.

### Static Methods

None

#### Checker (Constructor)

Checker(filename=None, lines=None, options=None, report=None, **kwargs)

#### Checker.build_tokens_line

build_tokens_line()

Build a logical line from tokens.

#### Checker.check_all

check_all(expected=None, line_offset=0)

Run all checks on the input file.

#### Checker.check_ast

check_ast()

Build the file's AST and run all AST checks.

#### Checker.check_logical

check_logical()

Build a line from tokens and run all logical checks on it.

#### Checker.check_physical

check_physical(line)

Run all physical checks on a raw input line.

#### Checker.generate_tokens

generate_tokens()

Tokenize file, run physical line checks and yield tokens.

#### Checker.init_checker_state

init_checker_state(name, argument_names)

Prepare custom state for the specific checker plugin.

#### Checker.maybe_check_physical

maybe_check_physical(token, prev_physical)

If appropriate for token, check current physical line(s).

#### Checker.readline

readline()

Get the next line from the input buffer.

#### Checker.report_invalid_syntax

report_invalid_syntax()

Check if the syntax is valid.

#### Checker.run_check

run_check(check, argument_names)

Run a check plugin.

Up

## DiffReport

Collect and print the results for the changed lines only.

### Derived from

StandardReport

### Class Attributes

None

### Class Methods

None

### Methods

DiffReport |
error |

### Static Methods

None

#### DiffReport (Constructor)

DiffReport(options)

#### DiffReport.error

error(line_number, offset, text, check)
Up

## FileReport

Collect the results of the checks and print the filenames.

### Derived from

BaseReport

### Class Attributes

print_filename

### Class Methods

None

### Methods

None

### Static Methods

None

Up

## StandardReport

Collect and print the results of the checks.

### Derived from

BaseReport

### Class Attributes

None

### Class Methods

None

### Methods

StandardReport |
error | Report an error, according to options.
error_args | Report an error, according to options.
get_file_results | Print results and return the overall count for this file.
init_file | Signal a new file.

### Static Methods

None

#### StandardReport (Constructor)

StandardReport(options)

#### StandardReport.error

error(line_number, offset, text, check)

Report an error, according to options.

#### StandardReport.error_args

error_args(line_number, offset, code, check, *args)

Report an error, according to options.

#### StandardReport.get_file_results

get_file_results()

Print results and return the overall count for this file.

#### StandardReport.init_file

init_file(filename, lines, expected, line_offset)

Signal a new file.

Up

## StyleGuide

Initialize a PEP-8 instance with few options.

### Derived from

None

### Class Attributes

None

### Class Methods

None

### Methods

StyleGuide |
check_files | Run all checks on the paths.
excluded | Check if the file should be excluded.
get_checks | Get all the checks for this category.
ignore_code | Check if the error code should be ignored.
init_report | Initialize the report instance.
input_dir | Check all files in this directory and all subdirectories.
input_file | Run all checks on a Python source file.

### Static Methods

None

#### StyleGuide (Constructor)

StyleGuide(*args, **kwargs)

#### StyleGuide.check_files

check_files(paths=None)

Run all checks on the paths.

#### StyleGuide.excluded

excluded(filename, parent=None)

Check if the file should be excluded.

Check if 'options.exclude' contains a pattern matching filename.

#### StyleGuide.get_checks

get_checks(argument_name)

Get all the checks for this category.

Find all globally visible functions where the first argument name starts with argument_name and which contain selected tests.

#### StyleGuide.ignore_code

ignore_code(code)

Check if the error code should be ignored.

If 'options.select' contains a prefix of the error code, return False. Else, if 'options.ignore' contains a prefix of the error code, return True.

#### StyleGuide.init_report

init_report(reporter=None)

Initialize the report instance.

#### StyleGuide.input_dir

input_dir(dirname)

Check all files in this directory and all subdirectories.

#### StyleGuide.input_file

input_file(filename, lines=None, expected=None, line_offset=0)

Run all checks on a Python source file.

Up

## _add_check

_add_check(check, kind, codes, args)
Up

## _break_around_binary_operators

_break_around_binary_operators(tokens)

Private function to reduce duplication.

This factors out the shared details between :func:`break_before_binary_operator` and :func:`break_after_binary_operator`.

Up

## _get_parameters

_get_parameters(function)
Up

## _is_binary_operator

_is_binary_operator(token_type, text)
Up

## _is_eol_token

_is_eol_token(token)
Up

## _is_one_liner

_is_one_liner(logical_line, indent_level, lines, line_number)
Up

## _main

_main()

Parse options and run checks on Python source.

Up

## _parse_multi_options

_parse_multi_options(options, split_token=', ')

Split and strip and discard empties.

Turns the following:

A, B,

into ["A", "B"]

Up

## ambiguous_identifier

ambiguous_identifier(logical_line, tokens)

Never use the characters 'l', 'O', or 'I' as variable names.

In some fonts, these characters are indistinguishable from the numerals one and zero. When tempted to use 'l', use 'L' instead.

Okay: L = 0 Okay: o = 123 Okay: i = 42 E741: l = 0 E741: O = 123 E741: I = 42

Variables can be bound in several other contexts, including class and function definitions, lambda functions, 'global' and 'nonlocal' statements, exception handlers, and 'with' and 'for' statements. In addition, we have a special handling for function parameters.

Okay: except AttributeError as o: Okay: with lock as L: Okay: foo(l=12) Okay: foo(l=I) Okay: for a in foo(l=12): Okay: lambda arg: arg * l Okay: lambda a=l[I:5]: None Okay: lambda x=a.I: None Okay: if l >= 12: E741: except AttributeError as O: E741: with lock as l: E741: global I E741: nonlocal l E741: def foo(l): E741: def foo(l=12): E741: l = foo(l=12) E741: for l in range(10): E741: [l for l in lines if l] E741: lambda l: None E741: lambda a=x[1:5], l: None E741: lambda **l: E741: def f(**l): E742: class I(object): E743: def l(x):

Up

## bare_except

bare_except(logical_line, noqa)

When catching exceptions, mention specific exceptions when possible.

Okay: except Exception: Okay: except BaseException: E722: except:

Up

## blank_lines

blank_lines(logical_line, blank_lines, indent_level, line_number, blank_before, previous_logical, previous_unindented_logical_line, previous_indent_level, lines)

Separate top-level function and class definitions with two blank lines.

Method definitions inside a class are separated by a single blank line.

Extra blank lines may be used (sparingly) to separate groups of related functions. Blank lines may be omitted between a bunch of related one-liners (e.g. a set of dummy implementations).

Use blank lines in functions, sparingly, to indicate logical sections.

Okay: def a():\n pass\n\n\ndef b():\n pass Okay: def a():\n pass\n\n\nasync def b():\n pass Okay: def a():\n pass\n\n\n# Foo\n# Bar\n\ndef b():\n pass Okay: default = 1\nfoo = 1 Okay: classify = 1\nfoo = 1

E301: class Foo:\n b = 0\n def bar():\n pass E302: def a():\n pass\n\ndef b(n):\n pass E302: def a():\n pass\n\nasync def b(n):\n pass E303: def a():\n pass\n\n\n\ndef b(n):\n pass E303: def a():\n\n\n\n pass E304: @decorator\n\ndef a():\n pass E305: def a():\n pass\na() E306: def a():\n def b():\n pass\n def c():\n pass E307: def a():\n def b():\n pass\n\n\n def c():\n pass E308: def a():\n\n\n\n pass

Up

## break_after_binary_operator

break_after_binary_operator(logical_line, tokens)

Avoid breaks after binary operators.

The preferred place to break around a binary operator is before the operator, not after it.

W504: (width == 0 +\n height == 0) W504: (width == 0 and\n height == 0) W504: var = (1 &\n ~2)

Okay: foo(\n -x) Okay: foo(x\n []) Okay: x = '''\n''' + '' Okay: x = '' + '''\n''' Okay: foo(x,\n -y) Okay: foo(x, # comment\n -y)

The following should be W504 but unary_context is tricky with these Okay: var = (1 /\n -2) Okay: var = (1 +\n -1 +\n -2)

Up

## break_before_binary_operator

break_before_binary_operator(logical_line, tokens)

Avoid breaks before binary operators.

The preferred place to break around a binary operator is after the operator, not before it.

W503: (width == 0\n + height == 0) W503: (width == 0\n and height == 0) W503: var = (1\n & ~2) W503: var = (1\n / -2) W503: var = (1\n + -1\n + -2)

Okay: foo(\n -x) Okay: foo(x\n []) Okay: x = '''\n''' + '' Okay: foo(x,\n -y) Okay: foo(x, # comment\n -y)

Up

## comparison_negative

comparison_negative(logical_line)

Negative comparison should be done using "not in" and "is not".

Okay: if x not in y:\n pass Okay: assert (X in Y or X is Z) Okay: if not (X in Y):\n pass Okay: zz = x is not y E713: Z = not X in Y E713: if not X.B in Y:\n pass E714: if not X is Y:\n pass E714: Z = not X.B is Y

Up

## comparison_to_singleton

comparison_to_singleton(logical_line, noqa)

Comparison to singletons should use "is" or "is not".

Comparisons to singletons like None should always be done with "is" or "is not", never the equality operators.

Okay: if arg is not None: E711: if arg != None: E711: if None == arg: E712: if arg == True: E712: if False == arg:

Also, beware of writing if x when you really mean if x is not None -- e.g. when testing whether a variable or argument that defaults to None was set to some other value. The other value might have a type (such as a container) that could be false in a boolean context!

Up

## comparison_type

comparison_type(logical_line, noqa)

Object type comparisons should always use isinstance().

Do not compare types directly.

Okay: if isinstance(obj, int): Okay: if type(obj) is int: E721: if type(obj) == type(1):

Up

## compound_statements

compound_statements(logical_line)

Compound statements (on the same line) are generally discouraged.

While sometimes it's okay to put an if/for/while with a small body on the same line, never do this for multi-clause statements. Also avoid folding such long lines!

Always use a def statement instead of an assignment statement that binds a lambda expression directly to a name.

Okay: if foo == 'blah':\n do_blah_thing() Okay: do_one() Okay: do_two() Okay: do_three()

E701: if foo == 'blah': do_blah_thing() E701: for x in lst: total += x E701: while t < 10: t = delay() E701: if foo == 'blah': do_blah_thing() E701: else: do_non_blah_thing() E701: try: something() E701: finally: cleanup() E701: if foo == 'blah': one(); two(); three() E702: do_one(); do_two(); do_three() E703: do_four(); # useless semicolon E704: def f(x): return 2*x E731: f = lambda x: 2*x

Up

## continued_indentation

continued_indentation(logical_line, tokens, indent_level, hang_closing, indent_char, indent_size, noqa, verbose)

Continuation lines indentation.

Continuation lines should align wrapped elements either vertically using Python's implicit line joining inside parentheses, brackets and braces, or using a hanging indent.

When using a hanging indent these considerations should be applied: - there should be no arguments on the first line, and - further indentation should be used to clearly distinguish itself as a continuation line.

Okay: a = (\n) E123: a = (\n )

Okay: a = (\n 42) E121: a = (\n 42) E122: a = (\n42) E123: a = (\n 42\n ) E124: a = (24,\n 42\n) E125: if (\n b):\n pass E126: a = (\n 42) E127: a = (24,\n 42) E128: a = (24,\n 42) E129: if (a or\n b):\n pass E131: a = (\n 42\n 24)

Up

## expand_indent

expand_indent(line)

Return the amount of indentation.

Tabs are expanded to the next multiple of 8.

Up

## explicit_line_join

explicit_line_join(logical_line, tokens)

Avoid explicit line join between brackets.

The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. Long lines can be broken over multiple lines by wrapping expressions in parentheses. These should be used in preference to using a backslash for line continuation.

E502: aaa = [123, \\n 123] E502: aaa = ("bbb " \\n "ccc")

Okay: aaa = [123,\n 123] Okay: aaa = ("bbb "\n "ccc") Okay: aaa = "bbb " \\n "ccc" Okay: aaa = 123 # \\

Up

## extraneous_whitespace

extraneous_whitespace(logical_line)

Avoid extraneous whitespace.

Avoid extraneous whitespace in these situations: - Immediately inside parentheses, brackets or braces. - Immediately before a comma, semicolon, or colon.

Okay: spam(ham[1], {eggs: 2}) E201: spam( ham[1], {eggs: 2}) E201: spam(ham[ 1], {eggs: 2}) E201: spam(ham[1], { eggs: 2}) E202: spam(ham[1], {eggs: 2} ) E202: spam(ham[1 ], {eggs: 2}) E202: spam(ham[1], {eggs: 2 })

E203: if x == 4: print x, y; x, y = y , x E203: if x == 4: print x, y ; x, y = y, x E203: if x == 4 : print x, y; x, y = y, x

Okay: @decorator E204: @ decorator

Up

## filename_match

filename_match(filename, patterns, default=True)

Check if patterns contains a pattern that matches filename.

If patterns is unspecified, this always returns True.

Up

## get_parser

get_parser(prog='pycodestyle', version=__version__)

Create the parser for the program.

Up

## imports_on_separate_lines

imports_on_separate_lines(logical_line)

Place imports on separate lines.

Okay: import os\nimport sys E401: import sys, os

Okay: from subprocess import Popen, PIPE Okay: from myclas import MyClass Okay: from foo.bar.yourclass import YourClass Okay: import myclass Okay: import foo.bar.yourclass

Up

## indentation

indentation(logical_line, previous_logical, indent_char, indent_level, previous_indent_level, indent_size)

Use indent_size (PEP8 says 4) spaces per indentation level.

For really old code that you don't want to mess up, you can continue to use 8-space tabs.

Okay: a = 1 Okay: if a == 0:\n a = 1 E111: a = 1 E114: # a = 1

Okay: for item in items:\n pass E112: for item in items:\npass E115: for item in items:\n# Hi\n pass

Okay: a = 1\nb = 2 E113: a = 1\n b = 2 E116: a = 1\n # b = 2

Up

## is_string_literal

is_string_literal(line)
Up

## maximum_doc_length

maximum_doc_length(logical_line, max_doc_length, noqa, tokens)

Limit all doc lines to a maximum of 72 characters.

For flowing long blocks of text (docstrings or comments), limiting the length to 72 characters is recommended.

Reports warning W505

Up

## maximum_line_length

maximum_line_length(physical_line, max_line_length, multiline, line_number, noqa)

Limit all lines to a maximum of 79 characters.

There are still many devices around that are limited to 80 character lines; plus, limiting windows to 80 characters makes it possible to have several windows side-by-side. The default wrapping on such devices looks ugly. Therefore, please limit all lines to a maximum of 79 characters. For flowing long blocks of text (docstrings or comments), limiting the length to 72 characters is recommended.

Reports error E501.

Up

## missing_whitespace

missing_whitespace(logical_line, tokens)

Surround operators with the correct amount of whitespace.

- Always surround these binary operators with a single space on either side: assignment (=), augmented assignment (+=, -= etc.), comparisons (==, <, >, !=, <=, >=, in, not in, is, is not), Booleans (and, or, not).

- Each comma, semicolon or colon should be followed by whitespace.

- If operators with different priorities are used, consider adding whitespace around the operators with the lowest priorities.

Okay: i = i + 1 Okay: submitted += 1 Okay: x = x * 2 - 1 Okay: hypot2 = x * x + y * y Okay: c = (a + b) * (a - b) Okay: foo(bar, key='word', *args, **kwargs) Okay: alpha[:-i] Okay: [a, b] Okay: (3,) Okay: a[3,] = 1 Okay: a[1:4] Okay: a[:4] Okay: a[1:] Okay: a[1:4:2]

E225: i=i+1 E225: submitted +=1 E225: x = x /2 - 1 E225: z = x **y E225: z = 1and 1 E226: c = (a+b) * (a-b) E226: hypot2 = x*x + y*y E227: c = a|b E228: msg = fmt%(errno, errmsg) E231: ['a','b'] E231: foo(bar,baz) E231: [{'a':'b'}]

Up

## missing_whitespace_after_keyword

missing_whitespace_after_keyword(logical_line, tokens)

Keywords should be followed by whitespace.

Okay: from foo import (bar, baz) E275: from foo import(bar, baz) E275: from importable.module import(bar, baz) E275: if(foo): bar

Up

## module_imports_on_top_of_file

module_imports_on_top_of_file(logical_line, indent_level, checker_state, noqa)

Place imports at the top of the file.

Always put imports at the top of the file, just after any module comments and docstrings, and before module globals and constants.

Okay: import os Okay: # this is a comment\nimport os Okay: '''this is a module docstring'''\nimport os Okay: r'''this is a module docstring'''\nimport os E402: a=1\nimport os E402: 'One string'\n"Two string"\nimport os E402: a=1\nfrom sys import x

Okay: if x:\n import os

Up

## mute_string

mute_string(text)

Replace contents with 'xxx' to prevent syntax matching.

Up

## normalize_paths

normalize_paths(value, parent=os.curdir)

Parse a comma-separated list of paths.

Return a list of absolute paths.

Up

## parse_udiff

parse_udiff(diff, patterns=None, parent='.')

Return a dictionary of matching lines.

Up

## process_options

process_options(arglist=None, parse_argv=False, config_file=None, parser=None, verbose=None)

Process options passed either via arglist or command line args.

Passing in the ``config_file`` parameter allows other tools, such as flake8 to specify their own options to be processed in pycodestyle.

Up

## python_3000_invalid_escape_sequence

python_3000_invalid_escape_sequence(logical_line, tokens, noqa)

Invalid escape sequences are deprecated in Python 3.6.

Okay: regex = r'\.png$' W605: regex = '\.png$'

Up

## read_config

read_config(options, args, arglist, parser)

Read and parse configurations.

If a config file is specified on the command line with the "--config" option, then only it is used for configuration.

Otherwise, the user configuration (~/.config/pycodestyle) and any local configurations in the current directory or above will be merged together (in that order) using the read method of ConfigParser.

Up

## readlines

readlines(filename)

Read the source code.

Up

## register_check

register_check(check, codes=None)

Register a new check object.

Up

## stdin_get_value

stdin_get_value()

Read the value from stdin.

Up

## tabs_obsolete

tabs_obsolete(physical_line)

On new projects, spaces-only are strongly recommended over tabs.

Okay: if True:\n return W191: if True:\n\treturn

Up

## tabs_or_spaces

tabs_or_spaces(physical_line, indent_char)

Never mix tabs and spaces.

The most popular way of indenting Python is with spaces only. The second-most popular way is with tabs only. Code indented with a mixture of tabs and spaces should be converted to using spaces exclusively. When invoking the Python command line interpreter with the -t option, it issues warnings about code that illegally mixes tabs and spaces. When using -tt these warnings become errors. These options are highly recommended!

Okay: if a == 0:\n a = 1\n b = 1

Up

## trailing_blank_lines

trailing_blank_lines(physical_line, lines, line_number, total_lines)

Trailing blank lines are superfluous.

Okay: spam(1) W391: spam(1)\n

However the last line should end with a new line (warning W292).

Up

## trailing_whitespace

trailing_whitespace(physical_line)

Trailing whitespace is superfluous.

The warning returned varies on whether the line itself is blank, for easier filtering for those who want to indent their blank lines.

Okay: spam(1)\n# W291: spam(1) \n# W293: class Foo(object):\n \n bang = 12

Up

## update_counts

update_counts(s, counts)

Adds one to the counts of each appearance of characters in s, for characters in counts

Up

## whitespace_around_comma

whitespace_around_comma(logical_line)

Avoid extraneous whitespace after a comma or a colon.

Note: these checks are disabled by default

Okay: a = (1, 2) E241: a = (1, 2) E242: a = (1,\t2)

Up

## whitespace_around_keywords

whitespace_around_keywords(logical_line)

Avoid extraneous whitespace around keywords.

Okay: True and False E271: True and False E272: True and False E273: True and\tFalse E274: True\tand False

Up

## whitespace_around_named_parameter_equals

whitespace_around_named_parameter_equals(logical_line, tokens)

Don't use spaces around the '=' sign in function arguments.

Don't use spaces around the '=' sign when used to indicate a keyword argument or a default parameter value, except when using a type annotation.

Okay: def complex(real, imag=0.0): Okay: return magic(r=real, i=imag) Okay: boolean(a == b) Okay: boolean(a != b) Okay: boolean(a <= b) Okay: boolean(a >= b) Okay: def foo(arg: int = 42): Okay: async def foo(arg: int = 42):

E251: def complex(real, imag = 0.0): E251: return magic(r = real, i = imag) E252: def complex(real, image: float=0.0):

Up

## whitespace_around_operator

whitespace_around_operator(logical_line)

Avoid extraneous whitespace around an operator.

Okay: a = 12 + 3 E221: a = 4 + 5 E222: a = 4 + 5 E223: a = 4\t+ 5 E224: a = 4 +\t5

Up

## whitespace_before_comment

whitespace_before_comment(logical_line, tokens)

Separate inline comments by at least two spaces.

An inline comment is a comment on the same line as a statement. Inline comments should be separated by at least two spaces from the statement. They should start with a # and a single space.

Each line of a block comment starts with a # and one or multiple spaces as there can be indented text inside the comment.

Okay: x = x + 1 # Increment x Okay: x = x + 1 # Increment x Okay: # Block comments: Okay: # - Block comment list Okay: # \xa0- Block comment list E261: x = x + 1 # Increment x E262: x = x + 1 #Increment x E262: x = x + 1 # Increment x E262: x = x + 1 # \xa0Increment x E265: #Block comment E266: ### Block comment

Up

## whitespace_before_parameters

whitespace_before_parameters(logical_line, tokens)

Avoid extraneous whitespace.

Avoid extraneous whitespace in the following situations: - before the open parenthesis that starts the argument list of a function call. - before the open parenthesis that starts an indexing or slicing.

Okay: spam(1) E211: spam (1)

Okay: dict['key'] = list[index] E211: dict ['key'] = list[index] E211: dict['key'] = list [index]

Up